var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var Item_Bag_CiTiao_UIBindings = require("AA_Item_Bag_CiTiao_UIBindings");
var ResKeeper = require("AA_ResKeeper");
var Excel = require("AA_Excel");
var PlayerDataManager = require("AA_PlayerDataManager");
var BundleConfig = require("AA_BundleConfig");
var CommonUtils = require("AA_CommonUtils");
var BagCiTiaoRichText = require("AA_BagCiTiaoRichText");
var UnLockLight = require("AA_UnLockLight");
var HallManager = require("AA_HallManager");
var Const_Game = require("AA_Const_Game");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_Item_Bag_CiTiao = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    t.ciTiaoComp = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.StartSet = function (e) {
    var t = this;
    var o = PlayerDataManager.PlayerDataMgr.GetEquipDataById(e.shuiguoId);
    this.openData = e;
    var n = this.openData.citiaomiaoshu;
    Excel.Excel.shuiguo(e.shuiguoId);
    this.ciTiaoComp.shuiGuoId = e.shuiguoId;
    this.ciTiaoComp.ciTiaoId = e.id;
    n = CommonUtils.default.replaceSymbols(n, "n", [""]);
    var i = Excel.Excel.shuiguobuff(this.openData.citiaoshuzhitype);
    var a = i ? i.value : null;
    var r = [n];
    -1 != n.indexOf("X") && (r = n.split("X"));
    var c = "";
    for (var s = 0; s < r.length; s++) {
      var u = r[s];
      if (-1 != u.indexOf("#")) {
        var l = "<img src='player" + (e.shuiguoId - 1e3) + "_5' click='ShowZaZhongInfo' />";
        u = CommonUtils.default.replaceSymbols(u, "#", [l]);
      }
      c += "<color=#ffffff>" + u + "</c>";
      s < r.length - 1 && a && (c += "<color=#71ff00>" + a[s] + "</c>");
    }
    if (o.level < this.openData.jiesuo || !o.isUnLock) {
      c = "<color=#a3f3ff><size=26>LV" + this.openData.jiesuo + "解锁:</s></c><color=#333333>" + c + "</c>";
    } else {
      if (!HallManager.HallMgr.GetCiTiaoIsLock(e.id)) {
        HallManager.HallMgr.SetCiTiaoIsLock(e.id);
        0 != this.node.getSiblingIndex() && this._loadRes(BundleConfig.BundleNames.Common, "common/" + "prefab/UnLockLight", cc.Prefab).then(function (e) {
          var o = cc.instantiate(e);
          o.parent = t.node;
          var n = t.auto_ui.node_bgFather.children[0];
          var i = cc.size(n.width, n.height);
          var a = n.getComponent(cc.Sprite).spriteFrame;
          o.getComponent(UnLockLight.default).StartSet(i, a, 1);
        });
      }
      e.shuiguoId == Const_Game.FruitId.紫薯精 && -1 != c.indexOf("猴天大圣") && (c = CommonUtils.default.replaceSymbols(c, "猴天大圣", ["<color=#00ff00>猴天大圣</c>"]));
      -1 != c.indexOf("CP技能") && (c = CommonUtils.default.replaceSymbols(c, "CP技能", ["<color=#ff0000>CP技能</c>"]));
    }
    c = "<outline color=#000000 width=3>" + (c = "<b>" + c + "</b>") + "</outline>";
    this.auto_ui.node_bgFather.children[0].active = o.level >= this.openData.jiesuo && o.isUnLock;
    this.auto_ui.node_bgFather.children[1].active = o.level < this.openData.jiesuo || !o.isUnLock;
    this.auto_ui.rtxt_infoLabel.string = c;
    this.LoadSprite(e.id);
  };
  _creator.prototype.LoadSprite = function (e) {
    return __awaiter(this, undefined, undefined, function () {
      var t = this;
      return __generator(this, function () {
        this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/skillicon/skill_" + e, cc.SpriteFrame).then(function (e) {
          t.auto_ui.sp_iconSprite.spriteFrame = e;
          CommonUtils.default.LimitSpriteMaxSize(t.auto_ui.sp_iconSprite, 70);
        });
        return [2];
      });
    });
  };
  __decorate([_property(Item_Bag_CiTiao_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  __decorate([_property(BagCiTiaoRichText.default)], _creator.prototype, "ciTiaoComp", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_Item_Bag_CiTiao;